from CvPythonExtensions import *

import GerikSpells
from GerikSpells import GerikSpellBase
from GSGroupPolicies import GSAll as GSGroup
from GSHandlerPolicies import GSImmediateNoTarget as GSHandler
from GSResultsPolicies import GSMissionNoTarget as GSResults

gc = CyGlobalContext()

class Haste(GerikSpellBase, GSGroup, GSHandler, GSResults):
    def __init__(self):
        GerikSpellBase.__init__(self)
        GSGroup.__init__(self)
        GSHandler.__init__(self)
        GSResults.__init__(self)

    def canUnitCast(self, pCastingUnit, pPlot, bVisible):
        iMinHitPoints = (pCastingUnit.maxHitPoints() / 3) + 1 # Roundoff
        if (pCastingUnit.currHitPoints() > iMinHitPoints):
            if (pCastingUnit.baseCombatStr() > 0):
                return True

        return False

    def startSpellResults(self, pCastingGroup, pTarget):
        for pUnit in pCastingGroup.getUnits():
            iChangeHitPoints = (pUnit.maxHitPoints() / 3) + 1 # Roundoff
            pUnit.changeDamage(iChangeHitPoints, pUnit.getOwner())
            pUnit.setMoves(0)
